import request from '@/utils/request'

/**
 * 获取员工简单列表
 * @returns Promise
 */
export function getEmployeeSimple() {
  return request({
    method: 'get',
    url: '/sys/user/simple'
  })
}

/**
 * 获取员工列表
 * @param {*} page 页码
 * @param {*} size 每页的条数
 * @returns
 */
export const getEmployeeList = (page = 1, size = 5) => {
  return request({
    method: 'get',
    url: '/sys/user',
    params: {
      page,
      size
    }
  })
}

/**
 * 根据id删除员工
 * @param {*} id id
 * @returns
 */
export const delEmployee = (id) => {
  return request({
    method: 'delete',
    url: '/sys/user/' + id
  })
}

/**
 * 新增员工
 * @param {*} data 表单数据
 * @returns
 */
export const addEmployee = (data) => {
  return request({
    method: 'post',
    url: '/sys/user',
    data
  })
}

/**
 * 批量导入员工
 * @param {*} Array 要的是数组
 * @returns
 */
export const importEmployee = (Array) => {
  return request({
    method: 'post',
    url: '/sys/user/batch',
    data: Array
  })
}

/**
 * 给员工分配角色
 * @param {*} id 员工id
 * @param {*} permIds 字符串数组
 * @returns
 */
export const assignRole = (id, roleIds) => {
  return request({
    method: 'put',
    url: '/sys/user/assignRoles',
    data: {
      id,
      roleIds
    }
  })
}
